package com.yunhe.assist.service.impl;

import com.yunhe.assist.client.FirmClient;
import com.yunhe.assist.service.HelpService;
import com.yunhe.common.model.ResultObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

import java.util.Map;
import java.util.Objects;
import java.util.function.Consumer;

@Service
public class HelpServiceImpl implements HelpService {
    @Autowired
    private FirmClient firmClient;

    @Override
    public void handleFirmByStationId(Long stationId, Consumer<Map> func) {
        if(Objects.isNull(stationId)){
            return;
        }
        ResponseEntity<ResultObject> firmRes =  firmClient.findFirmByStationId(stationId);
        if(Objects.isNull(firmRes)){
            return;
        }
        Map map = (Map) firmRes.getBody().getResults();
        if(Objects.nonNull(map)){
            func.accept(map);
        }
    }
}
